<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/WEB-INF/debug-tags.tld" prefix="d"%>
<html>
  <head>
    <title>Bug List</title>
	<link href="<s:url value="/css/admin.css"/>" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<s:url value="/js/select.js"/>"></script>
	<script type="text/javascript" src="<s:url value="/js/prototype.js"/>"></script>
	<script type="text/javascript">
		function print()
		{
			if(!isSelected())
			{
				alert('Select the data you want to print.');
				return;
			}
			frm.action='<s:url action="printdebug" includeParams="none"/>';
			frm.target='blank';
			frm.method='post';
			frm.submit();
		}
		function setPrinted()
		{
			if(!isSelected())
			{
				alert('Select a bug info first,please.');
				return;
			}
			frm.action='<s:url action="setdebugprinted" includeParams="none"/>';
			frm.target='';
			frm.method='post';
			frm.submit();
		}
		function query()
		{
			frm.action='<s:url action="debuglist" includeParams="none"/>';
			frm.target='';
			frm.method='get';
			frm.submit();
		}
		function isSelected()
		{
			var isSelected = false;
			var ids = document.getElementsByName('ids');
			for(var i=0;i<ids.length;i++)
			{
				if(ids[i].checked)
				{
					isSelected=true;
					break;
				}
			}
			return isSelected;
		}
		function over(tid)
		{
			tid.style.backgroundColor="#f9f9f9";
		}

		function out(tid)
		{
			tid.style.backgroundColor="#ffffff";
		}
	</script>
  </head>
  
  <body>
  <s:form action="debuglist" name="frm" method="get">
    <br><table width="78%"  border="1" align="center" cellpadding="0" cellspacing="0" style="border-collapse:collapse " frame="hsides">
  <tr>
    <td width="19%" align="right">Title:</td>
    <td width="31%"><s:textfield name="title"/> </td>
    <td width="18%" align="right">Tester:</td>
    <td width="32%"><s:select list="operatorList" listKey="userid" listValue="name" name="operator" headerKey="-1" headerValue="[ALL]"/> </td>
  </tr>
  <tr>
    <td align="right">Department:</td>
    <td><s:select list="departmentList" listKey="deptCode" listValue="name" name="deptCode" headerKey="" headerValue="[ALL]"/> </td>
    <td align="right">Developer:</td>
    <td><s:select list="userList" listKey="userid" listValue="name" name="userid" headerKey="-1" headerValue="[ALL]"/> </td>
  </tr>
  <tr>
    <td align="right">Status:</td>
    <td><s:select list="@com.debug.config.Constant@DEBUG_STATUS_MAP" name="status" headerKey="-1" headerValue="[ALL]"/> </td>
    <td align="right">Type:</td>
    <td><s:select list="@com.debug.config.Constant@DEBUG_TYPE_MAP" name="type" headerKey="-1" headerValue="[ALL]"/></td>
  </tr>
  <tr>
    <td align="right">System:</td>
    <td><s:select list="%{config.getSystem()}" headerKey="-1" headerValue="[ALL]" name="system"/></td>
    <td align="right">Page size:</td>
    <td><s:textfield name="pageSize" size="10"/> </td>
  </tr>
</table><br>
<center><input type="button" value=" Search " onclick="query();"/> <br><br>
</center>
    <table width="98%"  border="1" align="center" cellpadding="0" cellspacing="0" style="border-collapse:collapse ">
      <tr align="center">
        <td width="4%" height="25"><strong>Click</strong></td>
        <td width="28%"><strong>Title</strong></td>
        <td width="9%"><strong>Type</strong></td>
        <td width="8%"><strong>Developer</strong></td>
        <td width="12%"><strong>Auditing Date</strong></td>
        <td width="9%"><strong>Status</strong></td>
        <td width="8%"><strong>Tester</strong></td>
        <td width="5%"><strong>Man-hour</strong></td>
        <td width="5%"><strong>Printed</strong></td>
        <td width="12%"><strong>Operation</strong></td>
      </tr>
      <s:iterator value="list" status="i">
      <tr align="center" onMouseOver="over(this);" onMouseOut="out(this)">
        <td height="25"><input type="checkbox" name="ids" value="${id}"/> </td>
        <td align="left"><a href="<s:url action="viewdebug" includeParams="none"><s:param name="id" value="id"/></s:url>" target="blank"><s:property value="title"/></a></td>
        <td align="center"><s:property value="%{@com.debug.config.Constant@getString(type)}"/> </td>
        <td align="center"><s:property value="user.name"/> </td>
        <td align="center"><s:date name="auditDate" format="yyyy-MM-dd"/> </td>
        <td align="center"><s:property value="%{@com.debug.config.Constant@getString(status)}"/></td>
        <td align="center"><s:property value="operator.name"/> </td>
        <td align="center"><s:property value="times"/> </td>
        <td><s:property value="%{print?'√':'×'}"/> </td>
        <td>
        <s:url action="initprocessdebug" id="processurl" includeParams="none">
        	<s:param name="id" value="id"/> 
        </s:url>
        <a href="${processurl}">Process</a>
        </td>
      </tr>
      </s:iterator>
      <s:if test="%{list.size()<10}">
      <s:generator separator="" val="#{''}" count="%{10-list.size()}">
      <s:iterator>
      <tr align="center">
        <td height="25">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      </s:iterator>
      </s:generator>
      </s:if>
      <tr align="center">
        <td height="25" colspan="10" align="right"><d:page list="list"/> </td>
      </tr>
  </table>
    <br>

  <table width="93%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><input name="" type="checkbox" value="" onclick="javascript:{sAll(this,'frm.ids');}">
    ALL &nbsp;&nbsp;&nbsp;
    <input type="button" value=" Turn Over " onclick="javascript:{sReverse('frm.ids');}">
&nbsp;&nbsp;
<input type="button" name="Submit2" value=" Print" onclick="print();">
&nbsp;&nbsp;
<input type="button" name="Submit3" value="set to be printed" onclick="setPrinted();">&nbsp;&nbsp;<input type="button" name="Submit3" value="add a bug"  onclick="window.location='<s:url action="initsavedebug" includeParams="none"/>';"></td>
  </tr>
</table>

  </s:form>
</body>
</html>
